#ifndef __HDVB_STREAM_TAP_INTERFACE_H
#define __HDVB_STREAM_TAP_INTERFACE_H
/*
    libhdvbd - Library for building sophisticated DVB applications
    Copyright (C) 2012 Tony Houghton <h@realh.co.uk>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser general Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser general Public License for more details.

    You should have received a copy of the GNU Lesser general Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

/* Interface for an object which HdvbReceiver can use to tap TS stream
 * data eg to a gstreamer pipeline.
 */

#include <glib-object.h>

#include <hdvb/hdvb-lookup-service-pids.h>

G_BEGIN_DECLS

#define HDVB_TYPE_STREAM_TAP                (hdvb_stream_tap_get_type())
#define HDVB_STREAM_TAP(obj)                (G_TYPE_CHECK_INSTANCE_CAST((obj), \
                                            HDVB_TYPE_STREAM_TAP, \
                                            HdvbStreamTap))
#define HDVB_IS_STREAM_TAP(obj)             (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
                                            HDVB_TYPE_STREAM_TAP))
#define HDVB_STREAM_TAP_GET_INTERFACE(obj)  \
        (G_TYPE_INSTANCE_GET_INTERFACE((obj), \
        HDVB_TYPE_STREAM_TAP, \
        HdvbStreamTapInterface))

typedef struct _HdvbStreamTap               HdvbStreamTap;
typedef struct _HdvbStreamTapInterface      HdvbStreamTapInterface;


struct _HdvbStreamTapInterface {
    GTypeInterface parent_iface;
    
    void (*add_packet)(HdvbStreamTap *tap, const guint8 *data);
    void (*src_closed)(HdvbStreamTap *tap);
    const HdvbServicePidsInfo *(*get_pids_info)(HdvbStreamTap *tap);
};


GType
hdvb_stream_tap_get_type(void);


/**
 * hdvb_stream_tap_add_packet:
 * @tap: (transfer none):
 * @data: A packet of TS data.
 *
 * Called when a packet is ready to be added. Data must be copied or whatever
 * ASAP.
 */
void
hdvb_stream_tap_add_packet(HdvbStreamTap *tap, const guint8 *data);

/**
 * hdvb_stream_tap_src_closed:
 * @tap: (transfer none):
 *
 * Called if the receiver gets closed or if there's some sort of failure.
 * Implementations should delete themselves.
 */
void
hdvb_stream_tap_src_closed(HdvbStreamTap *tap);

/**
 * hdvb_stream_tap_get_pids:
 * @tap: (transfer none):
 * Returns: Info about the streams in the service the tap wants.
 */
const HdvbServicePidsInfo *
hdvb_stream_tap_get_pids_info(HdvbStreamTap *tap);


G_END_DECLS

#endif /* __HDVB_STREAM_TAP_INTERFACE_H */
